Open
Conversation
alexandruradovici
requested changes
Apr 3, 2023
| /// | ||
| /// This function is used both for synchronous and asynchronous readings | ||
|
|
||
| pub fn humidity_read() -> Result<(), ErrorCode> { |
There was a problem hiding this comment.
Suggested change
| pub fn humidity_read() -> Result<(), ErrorCode> { | |
| pub fn read() -> Result<(), ErrorCode> { |
| /// ## Hello | ||
| /// Returns Ok(humidity_value) if the operation was successful | ||
| /// humidity_value is returned in hundreds of centigrades | ||
| pub fn humidity_read_sync() -> Result<i32, ErrorCode> { |
There was a problem hiding this comment.
Suggested change
| pub fn humidity_read_sync() -> Result<i32, ErrorCode> { | |
| pub fn read_sync() -> Result<i32, ErrorCode> { |
There was a problem hiding this comment.
Are there any negative values for the humidity? You are using i32.
Comment on lines
+26
to
+40
| loop { | ||
| match Humidity::humidity_read_sync() { | ||
| Ok(hum_val) => writeln!( | ||
| Console::writer(), | ||
| "Humidity: {}{}.{}%\n", | ||
| if hum_val > 0 { "" } else { "-" }, | ||
| i32::abs(hum_val) / 100, | ||
| i32::abs(hum_val) % 100 | ||
| ) | ||
| .unwrap(), | ||
| Err(_) => writeln!(Console::writer(), "error while reading humidity",).unwrap(), | ||
| } | ||
|
|
||
| Alarm::sleep_for(Milliseconds(2000)).unwrap(); | ||
| } |
There was a problem hiding this comment.
Move this in the Ok branch of the previous match.
| MEMORY { | ||
| FLASH (X) : ORIGIN = 0x00040000, LENGTH = 256K | ||
| RAM (W) : ORIGIN = 0x20004000, LENGTH = 112K | ||
| RAM (W) : ORIGIN = 0x20004800, LENGTH = 112K |
| use libtock_humidity as humidity; | ||
| pub type Humidity = humidity::Humidity<super::runtime::TockSyscalls>; | ||
| pub use humidity::HumidityListener; | ||
| } No newline at end of file |
Comment on lines
+11
to
+13
| // The `upcall_on_command` field is set to Some(value) if an upcall(with value as its argument) should be called when read command is received, | ||
| // or None otherwise. It was needed for testing `read_sync` library function which simulates a synchronous temperature read, | ||
| // because it was impossible to schedule an upcall during the `synchronous` read in other ways. |
There was a problem hiding this comment.
Move this comment next to the field using ///
| fn command() { | ||
| let hum = Humidity::new(); | ||
|
|
||
| assert!(hum.command(EXISTS, 1, 2).is_success()); |
There was a problem hiding this comment.
What do the two arguments mean?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
added driver for the humidity sensor and tests